<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title>注册登记</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta name="viewport" content="width=device-width, user-scalable=no">
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta name=”apple-mobile-web-app-status-bar-style” content=”default”/>
    <meta name=”apple-mobile-web-app-status-bar-style” content=”black”/>
    <meta name=”apple-mobile-web-app-status-bar-style” content=”black-translucent”/>
    <meta content="telephone=no" name="format-detection">
    <meta content="email=no" name="format-detection">
    <meta name="format-detection" content="telephone=no"/>
    <script type="text/javascript" src="${s.base}/mobile/js/jquery-2.1.4.min.js"></script>
    <script type="text/javascript" src="${s.base}/mobile/js/fontSize.js"></script>
    <link rel="stylesheet" href="${s.base}/mobile/css/weui.min.css"/>
    <link rel="stylesheet" href="${s.base}/mobile/css/jquery-weui.css">
    <link rel="stylesheet" href="${s.base}/mobile/css/indexyq.css?126556456"/>
    <style>
        .cy-must {
            color: red !important;
        }
    </style>
</head>
<body>
<div class="content">
    <div class="topbanner"><img src="${s.base}/mobile/images/topimg.jpg"></div>
    <div class="blcokcont marb20">
        <div class="blockinput">
            <label><span class="cy-must">*</span>&nbsp;姓名</label>
            <input type="text" id="name" placeholder="请输入姓名" maxlength="18"/>
        </div>
        <div class="blockinput">
            <label><span class="cy-must">*</span>&nbsp;电话号码</label>
            <input type="text" id="mobile" placeholder="请输入电话号码" maxlength="11"/>
        </div>
        <div class="blockinput">
            <label><span class="cy-must">*</span>&nbsp;身份证号</label>
            <input type="text" id="idCard" placeholder="请输入身份证号" maxlength="18"/>
        </div>
        <div class="blockinput">
            <label>车牌号</label>
            <input type="text" id="carNumber" placeholder="请输入车牌号" maxlength="10"/>
        </div>
        <div class="blockinput">
            <label><span class="cy-must">*</span>&nbsp;楼栋号</label>
            <input type="text" id="buildingId" placeholder="请选择"/>
            <div class="block-line-hr"><img src="${s.base}/mobile/images/hr.png"></div>
        </div>
        <div class="blockinput">
            <label><span class="cy-must">*</span>&nbsp;住户号</label>
            <input type="text" id="buildingRoom" placeholder="如：1002室填写1002" maxlength="10"/>
        </div>
        <div class="blockinput">
            <label><span class="cy-must">*</span>&nbsp;是否外地返芜</label>
            <input type="text" id="returnStatus" placeholder="请选择"/>
            <div class="block-line-hr"><img src="${s.base}/mobile/images/hr.png"></div>
        </div>
        <div class="blockinput showReturn" style="display: none">
            <label><span class="cy-must">*</span>&nbsp;返芜日期</label>
            <input type="text" id="returnTime" placeholder="请选择"/>
            <div class="block-line-hr"><img src="${s.base}/mobile/images/hr.png"></div>
        </div>
        <div class="blockinput showReturn" style="display: none">
            <label><span class="cy-must">&nbsp;</span>&nbsp;返程地区</label>
            <input type="text" id="returnArea" placeholder="请输入返程地区" maxlength="1000"/>
        </div>
        <div class="blockinput showReturn" style="display: none">
            <label><span class="cy-must">*</span>&nbsp;是否经过疫区</label>
            <input type="text" id="epidemicArea" value="" placeholder="请选择"/>
            <div class="block-line-hr"><img src="${s.base}/mobile/images/hr.png"></div>
        </div>
    </div>
    <div class="sumitbtn">提交</div>
    <div class="miniwxts"><b>郑重提醒：</b>在疫情期间，公民必须如实填报个人信息，如故意隐瞒报错，将依法追究相关法律责任。</div>
</div>
</body>
<script type="text/javascript" src="${s.base}/mobile/js/common.js?1234"></script>
<script type="text/javascript" src="${s.base}/mobile/js/jquery-weui.js"></script>
<script type="text/javascript" src="${s.base}/mobile/js/constant.js?1234"></script>
<script>
    $(function () {
        /* $.fn.initSelect("#sexType", "性别", sexType);*/

        $.fn.initSelect('#returnStatus', '外地返芜', returnStatus, function (d) {
            if (isNotBlank(d.values)) {
                if (d.values === returnStatus[1].value) {
                    $('.showReturn').show()
                } else {
                    $('.showReturn').hide()
                }
            }
        })
        $.fn.initSelect('#epidemicArea', '经过疫区', epidemicArea)

        $('#returnTime').calendar({ dateFormat: 'yyyy-mm-dd' })

        $.fn.doPost('/phone/antiepidemic/building/list', { applyId: '${applyId}', communityId: '${communityId}' }, function (result) {
            if (result.code === 0) {
                $.fn.initSelect('#buildingId', '楼栋号', result.data)
            } else {
                $.toast(result.msg, 'text')
            }
        })

        //点击提交按钮
        $('.sumitbtn').bind('click', function () {
            if (isBlank($('#name').val())) {
                $.toast('请输入姓名', 'text')
                return false
            }
            /*if (isBlank($('#sexType').val())) {
                $.toast("请选择性别", "text");
                return false;
            }*/
            if (isBlank($('#mobile').val())) {
                $.toast('请输入电话号码', 'text')
                return false
            } else {
                var phone = /^[1][0-9]{10}$/
                if (!phone.test($('#mobile').val())) {
                    $.toast('电话号码格式不正确', 'text')
                    return false
                }
            }
            if (isBlank($('#idCard').val())) {
                $.toast('请输入身份证号', 'text')
                return false
            } else {
                var idNumber = /^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/
                if (!idNumber.test($('#idCard').val())) {
                    $.toast('身份证号格式不正确', 'text')
                    return false
                }
            }
            if (isBlank($('#buildingId').val())) {
                $.toast('请选择楼栋号', 'text')
                return false
            }
            if (isBlank($('#buildingRoom').val())) {
                $.toast('请输入住户号', 'text')
                return false
            } else {
                var buildingRoom = /^[0-9a-zA-Z]{1,10}$/
                if (!buildingRoom.test($('#buildingRoom').val())) {
                    $.toast('住户号格式不正确', 'text')
                    return false
                }
            }
            if (isBlank($('#returnStatus').val())) {
                $.toast('请选择是否外地返芜', 'text')
                return false
            } else {
                if ($('#returnStatus').attr('data-values') === returnStatus[1].value) {
                    if (isBlank($('#returnTime').val())) {
                        $.toast('请输入返芜日期', 'text')
                        return false
                    }
                    if (isBlank($('#epidemicArea').val())) {
                        $.toast('请选择是否经过疫区', 'text')
                        return false
                    }
                } else {
                    $('#returnTime').val('')
                    $('#returnArea').val('')
                    $('#epidemicArea').val('')
                    $('#epidemicArea').attr('data-values', '')
                }
            }

            var data = {
                name: $('#name').val(),
                mobile: $('#mobile').val(),
                idCard: $('#idCard').val(),
                carNumber: $('#carNumber').val(),
                buildingId: $('#buildingId').attr('data-values'),
                buildingRoom: $('#buildingRoom').val(),
                returnStatus: $('#returnStatus').attr('data-values'),
                returnTime: $('#returnTime').val(),
                returnArea: $('#returnArea').val(),
                epidemicArea: $('#epidemicArea').attr('data-values'),
                applyId: '${applyId}',
                memberId: '${memberId}'
            }
            if ('${checkType}' === '1') {
                data.verifyStatus = '1'
            } else if ('${checkType}' === '2') {
                data.verifyStatus = '0'
            }
            $.fn.doPost('/phone/antiepidemic/person/addOrUpdate', data, function (result) {
                if (result.code === 0) {
                    if ('${checkType}' === '1') {
                        window.location.href = '/phone/antiepidemic/index?token=${token}&applyId=${applyId}&communityId=${communityId}'
                    } else if ('${checkType}' === '2') {
                        window.location.href = '/phone/antiepidemic/checking'
                    }
                } else {
                    $.toast(result.msg, 'text')
                }
            })
        })
    })
</script>
</html>